// HashRouter：哈希路由
// BrowserRouter：普通路由
import './App.css';
import router from '@/router/index'
import Layout from "@/pages/Layout"
import { useRoutes, useLocation, Navigate } from 'react-router-dom'
import { ReactNode } from 'react';
import { AuthRoute } from './components/AuthRoute'


function App() {
  const outlet = useRoutes(router)

  // 获取路由
  const location = useLocation();
  // 解构
  const { pathname } = location
  // 面包屑导航
  const arr = pathname.split('/')
  const paths = arr.filter(i => i) //获取路径

  const layout = (): ReactNode => {
    if (paths[0] == 'login') {
      return (
        <div>{outlet}</div>
      )
    } else {
      return (
        AuthRoute(<Layout />)
      )
    }
  }

  return (
    <div className="App">
      <header className="App-header">
        {/* <Router></Router> */}
        {layout()}
      </header>
    </div >
  );
}

export default App;
